Vue.component('myheader',{
    template:`
     <header>
        <div class="c900 flex">
            <a href="./"><h1>天下行汽车租赁平台</h1></a>
            <span class="flex">
                <a v-if="!myinfo.id" href="register.html">注册</a>
                <a v-if="!myinfo.id" href="login.html">登录</a>
                <a v-if="myinfo.id">
                    <el-avatar :src="myinfo.headimg"></el-avatar>
                </a>
                <a v-if="myinfo.id" href="addCar.html">添加车辆</a>
                <a v-if="myinfo.id" href="orders.html">我的订单</a>
                <a v-if="myinfo.id" href="LogoutServlet.s">退出</a>
            </span>
        </div>
    </header>`,
    data(){
        return {
            myinfo:{
            }
        }
    },
    created(){
        axios.get("MyInfoServlet.s").then(res=>{
            if (res.data.code){
                this.myinfo = res.data.data;
            }else {
                this.myinfo = {};
            }
        });
    }
})